var v = "";
$(function(){
	v = new Vue({
		el:"#app",
		data:{
			reqUrl:"/account/index.php/",
			pdata:{},
			edata:{}
		},
		methods:{
			getList:function(){
				$.get(
					this.reqUrl+"Category/lists",
					function(reg){
						if(reg.status == "success"){
							v.pdata = reg.reson;
						}else{
							layer.msg(reg.reson);
						}
					}
				);
			},
			refresh:function(){
				window.location.reload();
			},
			add:function(){
				window.location.href="/account/h/addClass.html";
			},
			edit:function(){
				var id = $(event.path[2]).children("td").eq(0).text();
				$.post(
					this.reqUrl+"Category/one",
					{
						id:id
					},
					function(reg){
						if(reg.status == "success"){
							v.edata = reg.reson;
						}else{
							layer.msg(reg.reson);
						}
					}
				);
			},
			editSubmit:function(){
				$.post(
					this.reqUrl+"Category/editHandle",
					{
						id:$("#id").val(),
						name:$("#name").val()
					},
					function(reg){
						if(reg.status == "success"){
							layer.msg(reg.reson,{icon:1});
							setTimeout(function(){
								window.location.reload();
							},1500);
						}else{
							layer.msg(reg.reson,{icon:2});
						}
					}
				);
			}
		},
		ready:function(){
			this.getList();
		}
	});
});